package com.ls.modules.sys.biz.manager;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ls.base.utils.PageUtils;
import com.ls.base.utils.Query;
import com.ls.modules.sys.dal.mybatis.dao.DemoMapper;
import com.ls.modules.sys.dal.mybatis.entity.DemoEntity;
import jdk.nashorn.internal.runtime.logging.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author: xiaosu
 * @date: 2018-09-17  13:42
 */

@Service("testService")
public class TestService extends ServiceImpl<DemoMapper, DemoEntity> implements IService<DemoEntity> {

    @Transactional(rollbackFor =Exception.class)
    public void insertEntity() {


        DemoEntity entity = new DemoEntity();

        entity.setName("xiaosu");

        baseMapper.insert(entity);
        baseMapper.update(entity,new UpdateWrapper<DemoEntity>()
        .set("name","xiaoyu")
        );
    }



    public PageUtils queryPage(Map<String, Object> params) {

        IPage<DemoEntity> page=this.baseMapper.selectPage(
                new Query(params).getPage(),
                new QueryWrapper<DemoEntity>()
                        .like("name",params.get("name"))
                      );


        return new PageUtils(page);
    }

}
